<?php require_once('../Connections/gabriel_paris.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE caracteristicas SET nombre=%s, descripcion_breve=%s, descripcion=%s, id_barrio=%s WHERE id_caracteristica=%s",
                       GetSQLValueString($_POST['nombre'], "text"),
                       GetSQLValueString($_POST['descripcion_breve'], "text"),
                       GetSQLValueString($_POST['descripcion'], "text"),
                       GetSQLValueString($_POST['id_barrio'], "int"),
                       GetSQLValueString($_POST['id_caracteristica'], "int"));

  mysql_select_db($database_gabriel_paris, $gabriel_paris);
  $Result1 = mysql_query($updateSQL, $gabriel_paris) or die(mysql_error());

  $updateGoTo = "barrios_editar.php?id_barrio=".$_POST['id_barrio'];
 
  header(sprintf("Location: %s", $updateGoTo));
}

$colname_pagina = "-1";
if (isset($_GET['id_caracteristica'])) {
  $colname_pagina = $_GET['id_caracteristica'];
}
mysql_select_db($database_gabriel_paris, $gabriel_paris);
$query_pagina = sprintf("SELECT id_caracteristica, nombre, descripcion_breve, descripcion, id_barrio FROM caracteristicas WHERE id_caracteristica = %s", GetSQLValueString($colname_pagina, "int"));
$pagina = mysql_query($query_pagina, $gabriel_paris) or die(mysql_error());
$row_pagina = mysql_fetch_assoc($pagina);
$totalRows_pagina = mysql_num_rows($pagina);

 /* if not logged in then back to login page */
   session_start();

  if(!isset($_SESSION['is_successful_login']) || $_SESSION['is_successful_login'] == false){ 
    header ('location: index.php'); exit;
  }


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="../css/style3.css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.cycle.all.min.js"></script>
<script type="text/javascript" src="js/jcarousellite_1.0.1.min.js"></script>
<script type="text/javascript" src="js/jquery.easing.1.3.js"></script>
<script type="text/javascript" src="js/vida.js"></script>
<script type="text/javascript" src="js/menu.js"></script>
<script type="text/javascript" src="../ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="../ckfinder/ckfinder.js"></script>


<title>G. Tavella | Asesores Inmobiliarios</title>
</head>

<body>
<?php include('header.php'); ?>

<div id="container">
<div class="wrapper">

	<div id="contenedor" class="clearfix">
    	<div class="clearfix">
            <div id="sidebar">
                <?php include('menu_propiedades.php'); ?>

            </div>
            <!-- fin Sidebar -->
            
          <div id="contenido">
           <div class="item">
             <h2>Barrios Cerrados - Pagina Nueva</h2>
            </div>
           <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
             <table width="100%" align="left">
               
               <tr valign="baseline">
                 <td nowrap="nowrap" align="right">Nombre:</td>
                 <td><input type="text" name="nombre" value="<?php echo htmlentities($row_pagina['nombre'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
               </tr>
               <tr valign="baseline">
                 <td nowrap="nowrap" align="right">Descripcion Breve:</td>
                 <td><textarea name="descripcion_breve" cols="110"><?php echo htmlentities($row_pagina['descripcion_breve'], ENT_COMPAT, 'utf-8'); ?></textarea></td>
               </tr>
               <tr valign="baseline">
                 <td nowrap="nowrap" align="right">Descripcion:</td>
                 <td>
                   <input type="hidden" name="id_barrio" value="<?php echo htmlentities($row_pagina['id_barrio'], ENT_COMPAT, 'utf-8'); ?>"  />
                 <textarea name="descripcion"><?php echo htmlentities($row_pagina['descripcion'], ENT_COMPAT, 'utf-8'); ?></textarea>
                  <script type="text/javascript">
					    var editor = CKEDITOR.replace( 'descripcion' );
                        CKFinder.setupCKEditor( editor, '../ckfinder/' );
	             </script>
                 </td>
               </tr>
              
                <tfoot>
               <tr>
                <td colspan="5" >
                  <input type="button" onclick="javascript:history.back(1)" style="float:left;margin-right:10px" class="btn" value="Cancelar" />
                  <input type="submit" class="btn" value="Guardar" /></td>
               </tr>
              </tfoot>
             </table>
             <input type="hidden" name="MM_update" value="form1" />
             <input type="hidden" name="id_caracteristica" value="<?php echo $row_pagina['id_caracteristica']; ?>" />
           </form>
           <p>&nbsp;</p>
          </div>
        
       	</div>
</div>
</div>
</div>
<?php include('footer.php'); ?>
</body>
</html>
<?php
mysql_free_result($pagina);
?>
